home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / brailler-04b-c / brlr ƒ / Shell ƒ / about.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  2.8 KB  |  116 lines  |  [TEXT/MMCC]

  1. #include "about.h"
  2. #include "prefs.h"
  3. #include "util.h"
  4. #include "window layer.h"
  5. #include "graphics.h"
  6.  
  7. /*-----------------------------------------------------------------------------------*/
  8. /* internal stuff for about.c                                                        */
  9.  
  10. static    void GetTheNextLine(Handle textHandle, unsigned long theSize, unsigned long *pos, Str255 theLine);
  11. static    void DrawTheAboutString(Str255 theString, short *theRow, short theCenter);
  12.  
  13. static    Boolean            gUseAlternate;
  14.  
  15. void SetupTheAboutWindow(WindowPtr theWindow)
  16. {
  17.     unsigned char    *titleStr="\pAbout";
  18.     
  19.     SetWindowWidth(theWindow, 170);
  20.     SetWindowHeight(theWindow, 216);
  21.     SetWindowType(theWindow, noGrowDocProc);
  22.     SetWindowTitle(theWindow, titleStr);
  23.     SetWindowHasCloseBox(theWindow, TRUE);
  24.     SetWindowMaxDepth(theWindow, 1);
  25.     SetWindowDepth(theWindow, 1);
  26.     SetWindowIsFloat(theWindow, FALSE);
  27.     SetWindowAutoCenter(theWindow, TRUE);
  28. }
  29.  
  30. void OpenTheAboutWindow(WindowPtr theWindow)
  31. {
  32.     KeyMap            rawKeys;
  33.     unsigned short    theKeys[8];
  34.     
  35.     GetKeys(rawKeys);
  36.     Mymemcpy((Ptr)theKeys, (Ptr)rawKeys, sizeof(rawKeys));
  37.     if (theKeys[3]&4)    /* option key down? */
  38.     {
  39.         if (!gUseAlternate)
  40.             gUseAlternate=TRUE;
  41.     }
  42.     else
  43.     {
  44.         if (gUseAlternate)
  45.             gUseAlternate=FALSE;
  46.     }
  47. }
  48.  
  49. void DrawTheAboutWindow(WindowPtr theWindow, short theDepth)
  50. {
  51.     short            row;
  52.     Handle            textHandle;
  53.     Str255            theLine;
  54.     unsigned long    pos;
  55.     unsigned long    theSize;
  56.     GrafPtr            curPort;
  57.     short            theCenter;
  58.     RGBColor        myGray={49152, 49152, 49152};
  59.     Boolean            isColor;
  60.     
  61.     isColor=(theDepth>2);
  62.     GetPort(&curPort);
  63.     FillRect(&(curPort->portRect), &qd.black);
  64.     TextMode(srcXor);
  65.     
  66.     theCenter=(curPort->portRect.right-curPort->portRect.left)/2;
  67.     
  68.     TextFont(geneva);
  69.     TextSize(9);
  70.     row=16;
  71.     textHandle=GetResource('TEXT', gUseAlternate ? 129 : 128);
  72.     if (textHandle==0L)
  73.         return;
  74.     if (*textHandle==0L)
  75.         LoadResource(textHandle);
  76.     if (*textHandle==0L)
  77.         return;
  78.     pos=0L;
  79.     theSize=SizeResource(textHandle);
  80.     do
  81.     {
  82.         GetTheNextLine(textHandle, theSize, &pos, theLine);
  83.         DrawTheAboutString(theLine, &row, theCenter);
  84.     }
  85.     while (pos<theSize);
  86.     ReleaseResource(textHandle);
  87.     DrawTheAboutString(gMyName, &row, theCenter);
  88.     DrawTheAboutString(gMyOrg, &row, theCenter);
  89. }
  90.  
  91. void KeyDownInAboutWindow(WindowPtr theWindow, unsigned char theChar)
  92. {
  93.     CloseTheWindow(theWindow);
  94. }
  95.  
  96. void MouseDownInAboutWindow(WindowPtr theWindow, Point thePoint)
  97. {
  98.     CloseTheWindow(theWindow);
  99. }
  100.  
  101. static    void GetTheNextLine(Handle textHandle, unsigned long theSize, unsigned long *pos, Str255 theLine)
  102. {
  103.     unsigned char    theChar;
  104.     
  105.     theLine[0]=0x00;
  106.     while ((*pos<theSize) && ((theChar=*((unsigned char*)(((long)(*textHandle))+((*pos)++))))!=0x0d))
  107.         theLine[++theLine[0]]=theChar;
  108. }
  109.  
  110. static    void DrawTheAboutString(Str255 theString, short *theRow, short theCenter)
  111. {
  112.     MoveTo(theCenter-StringWidth(theString)/2, *theRow);
  113.     DrawString(theString);
  114.     *theRow+=12;
  115. }
  116.